package com.wangs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    RestTemplate restTemplate;

    @RequestMapping("/add")
    public String add() {
        String msg = restTemplate.getForObject("http://stock-service/stock/reduce", String.class);
        return "hello 添加成功！" + msg;
    }

    @RequestMapping("/header")
    public String header(@RequestHeader("X-Request-color") String color) {
        return color;
    }

}
